//****************************************************************
// Autor:   Yimy Juarez 
//       
// Seccion: 10
// Nombre del Archivo: StackVector.java
// Fecha de Modificacion:17/07/2012
// Descripcion:
// Modelado implementación de interfaz Stack
// ***************************************************************
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package hojatrabajo2;

import java.util.Vector;

/**
 *
 * @param <E> cualquier tipo de objeto genérico
 * @author Roberto
 */
public class StackVector<E> implements Stack<E> {
    
   protected Vector<E> data;

	public StackVector()
	// post: constructs a new, empty stack
	{
		data = new Vector<E>();
	}

	/**
     *
     * @param item the value of item
     */
    public void push(E item)
	// post: the value is added to the stack
	//          will be popped next if no intervening push
	{
		data.add(item);
	}

	/**
     *
     */
    public E pop()
	// pre: stack is not empty
	// post: most recently pushed item is removed and returned
	{
		return data.remove(size()-1);
	}

	/**
     *@return ultimo elemento en la pila
     */
    public E peek()
	// pre: stack is not empty
	// post: top value (next to be popped) is returned
	{
		return data.get(size() - 1);
	}
	
	/**
     *
     * @return the int
     */
    public int size()
	// post: returns the number of elements in the stack
	{
		return data.size();
	}
  
	/**
     *
     *
     * @return Verdadero si la pila esta vacia
     */
    public boolean empty()
	// post: returns true if and only if the stack is empty
	{
		return size() == 0;
    
        }
}
